home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
dskut
/
fhard101.zip
/
VHCACHE.ASM
< prev
next >
Wrap
Assembly Source File
|
1990-07-23
|
17KB
|
678 lines
title Manage the VHARD FAT cache
subttl Prologue
page 60,132
comment {
******************************************************************************
File VHCACHE.ASM
Author:
Aaron L. Brenner
BIX mail address albrenner
GEnie address A.BRENNER
This program is hereby released to the public domain.
Purpose:
Provide a command-driven interface to the VHARD FAT/root dir cache.
Command syntax:
VHCACHE [? | ON | OFF | MANUAL | AUTO | FLUSH]
Parameters:
? or INFO Display information about the cache.
ON Enable the cache.
OFF Disable and remove the cache.
MANUAL Disable auto-flush.
AUTO Enable auto-flush.
FLUSH Write the cache to disk.
If no parameters, a brief usage message is displayed.
ERRORLEVEL returned:
0 The requested operation was performed successfully.
1 An error was reported by the driver.
2 Command syntax error.
3 VHARD.SYS not installed.
4 Invalid DOS version
5 Insufficient free memory
Notes:
All commands (including "?") require that VHARD.SYS be installed.
Revision history:
1.00 07/20/90 ALB Created.
******************************************************************************
endcomment {
subttl Included files
page
include dd_defs.inc
include vhard.inc
subttl Program stack and data
page
vhcache_stack segment stack
dw 128 dup (0)
vhcache_stack ends
vhcache_data segment
assume ds:vhcache_data
ax_value dw 4c00h
dx_value dw 0
vhctl_handle dw 0
vhctl_name db 'VHARDCTL',0
vhard_drive db 0ffh ; Drive assigned (FF = unavailable)
vhard_ver dw 0 ; BCD version of driver
vhard_BPB DOS_BPB <> ; BPB for the driver (we ignore it)
cache_flags db 0 ; Flags for the cache if installed
cache_addr dw 0, 0 ; Address of current cache
cmd_block VH_CMD <>
cmd_keyword db 8 dup (0) ; The keyword on the command line
vhversion db 'VHARD version is $'
vhdrive_is db 'VHARD is using drive letter $'
cached_at db 'Currently installed cache is at $'
needs_flushing db 'Cache needs to be FLUSHed', 13, 10, '$'
auto_enabled db 'AUTOflush is enabled', 13, 10, '$'
;
; Error messages
;
no_share db 'SHARE.EXE must be run before AUTOflush can be'
db ' enabled.', 13, 10, '$'
bad_dos_ver db 'Invalid DOS version for AUTOflush.', 13, 10, '$'
no_memory db 'Not enough memory', 13, 10, '$'
no_cache db 'The cache is not yet installed', 13, 10, '$'
unk_err db 'unknown error$'
em1 db 'drive not read$'
em2 db 'seek error$'
em3 db 'general failure$'
em4 db 'CRC error$'
em5 db 'DMA boundary error$'
em6 db 'DMA overrun$'
em7 db 'sector not found$'
em8 db 'diskette is write-protected$'
em9 db 'address mark not found$'
em10 db 'unknown BIOS command$'
em11 db 'unknown VHARD command$'
em12 db 'cache already installed$'
em13 db 'cache not installed$'
em14 db 'cache must be flushed$'
err_prefix db 'Error: $'
crlf_str db 13, 10, '$'
error_messages dw unk_err
dw em1
dw em2
dw em3
dw em4
dw em5
dw em6
dw em7
dw em8
dw em9
dw em10
dw em11
dw em12
dw em13
dw em14
;
; Keywords we recognize
;
kw1 db 1,'?'
kw11 db 4,'INFO'
kw2 db 2,'ON'
kw3 db 3,'OFF'
kw4 db 6,'MANUAL'
kw5 db 4,'AUTO'
kw6 db 5,'FLUSH'
keywords dw kw1, kw_info
dw kw11, kw_info
dw kw2, kw_on
dw kw3, kw_off
dw kw4, kw_manual
dw kw5, kw_auto
dw kw6, kw_flush
dw 0
usage_msg db 'VHCACHE v1.00 - Public Domain Software', 13, 10
db 13, 10, 'Usage: VHPREP [? | ON | OFF | MANUAL | AUTO'
db ' | FLUSH]', 13, 10
db 13, 10, '? or INFO Display information on the cache'
db 13, 10, 'ON Enable the cache'
db 13, 10, 'OFF Disable and remove the cache'
db 13, 10, 'MANUAL Disable auto-flush'
db 13, 10, 'AUTO Enable auto-flush'
db 13, 10, 'FLUSH Write the cache to disk'
db 13, 10, '$'
bad_kw db 'Unknown keyword: "$'
bad_kw2 db '".', 13, 10, '$'
no_driver db 'VHARD.SYS must be installed', 13, 10, '$'
vhcache_data ends
subttl Start of program code
page
vhcache_code segment
assume cs:vhcache_code, ds:nothing, es:nothing, ss:vhcache_stack
start proc
call initialize ; Do program initialization
assume ds:vhcache_data
call do_command ; Do the command they want
mov ax,ax_value ;
mov dx,dx_value ;
int 21h ;
start endp
;*****************************************************************************
;
; Perform once-only program initialization.
;
;*****************************************************************************
initialize proc near
mov ax,vhcache_data ; Get our data segment
mov es,ax ;
assume es:vhcache_data
mov si,81h ; Point to the command tail
cld ; Make sure of direction
init_l1:
lodsb ; Get a character
cmp al,' ' ; Is it a blank?
je init_l1 ; Yep - ignore it
cmp al,9 ; Tab?
je init_l1 ; Yes - ignore it
cmp al,0dh ; End of the line?
jne init_l2 ; No - copy the keyword
push es ; Set DS aright
pop ds ;
assume ds:vhcache_data
mov dx,offset usage_msg ; Display the usage message
mov ah,9 ;
int 21h ;
mov ax,4c02h ; Pretend it's an error
int 21h ; Exit to DOS
init_l2:
assume ds:nothing
dec si ; Point back to where we stopped
mov di,offset cmd_keyword[1]; Point to where we're copying to
mov cx,6 ; Max we want to copy
init_l3:
lodsb ; Get the next byte
cmp al,' ' ; Done with the command?
je init_l5 ; Yes - stop copying
cmp al,9 ; Done with it?
je init_l5 ; Yes - stop copying
cmp al,0dh ; End of the line?
je init_l5 ; Yes - stop copying
jcxz init_l3 ; If the name buffer's full, ignore
cmp al,'a' ; Is it lower case?
jb init_l4 ; No - use it
cmp al,'z' ; Is it?
ja init_l4 ; Nope - use it
xor al,20h ; Make it upper case
init_l4:
stosb ; Put it in the name buffer
inc cmd_keyword[0] ; Count this character
dec cx ; Both ways
jmp short init_l3 ; Loop back for more
init_l5:
sub al,al ; Terminate it, too
stosb ;
push es ; Swap segments so we can release our
push ds ; environment
pop es ;
pop ds ;
assume ds:vhcache_data, es:nothing
mov es,es:[2ch] ; Get our environment segment
mov ah,49h ; Fn to release memory
int 21h ;
push ds ; Lastly, set ES to our data seg
pop es ;
assume es:vhcache_data
mov dx,offset vhctl_name ; Try to get to the VHARDCTL device
mov ax,3c02h ;
int 21h ;
jnc init_l6 ; If we could, make sure it's a device
init_err:
mov dx,offset no_driver ; Complain that the driver's missing
mov ah,9 ;
int 21h ;
mov ax,4c03h ; Exit with appropriate code
int 21h ;
init_l6:
mov bx,ax ; Get the handle for it
mov vhctl_handle,ax ; Save it for later use, too
mov ax,4400h ; Get info on the handle
int 21h ;
test dl,80h ; Is this a device?
jz init_err ; No - just a file, so complain
mov cmd_block.VC_cmd_code,CMD_GETDATA; Get driver info
mov word ptr cmd_block.VC_buffer[0],offset vhard_drive
mov word ptr cmd_block.VC_buffer[2],ds
mov dx,offset cmd_block ; Write it out to the driver
mov cx,size VH_CMD ;
mov ax,4403h ;
int 21h ;
ret ; Return to Main
initialize endp
;*****************************************************************************
;
; Perform the command specified by cmd_keyword.
;
;*****************************************************************************
do_command proc near
sub bx,bx ; Start at the base of the table
mov cx,bx ;
docm_l1:
mov di,keywords[bx] ; Pick up a keyword pointer
or di,di ; Hit the end of the table?
jnz docm_l2 ; No - see if they match
mov dx,offset bad_kw ; Report an unknown keyword
mov ah,9 ;
int 21h ;
mov dx,offset cmd_keyword[1]; Display the errant keyword
mov cl,cmd_keyword[0] ;
sub ch,ch ;
mov bx,1 ;
mov ah,40h ;
int 21h ;
mov dx,offset bad_kw2 ; Finish out the message
mov ah,9 ;
int 21h ;
mov ax,4c02h ; Exit with error code
int 21h ;
docm_l2:
mov si,offset cmd_keyword ; Point to the keyword they entered
mov cl,[